/*=========================================
       Remote Controlled Toy Vehicle
      Control your own little RC toy!
           by ~-=Cyanide SR71=-~
           Vote for Shadow Dragons!
       http://sdragons.mooglecave.com
=========================================*/
/*~------------~=Updates=~----------------~
  V1.0  Started script. Works Great!
-----------------------------------------*/
if (created) {
this.maxspeed=1;
this.startspeed=0.05;
this.accel=.05;
this.accelcount=5;
}
if (playerenters) {
this.fired=0;
this.speed=0;
hideimg 0;
showlocal;
timeout=0.05;
}
if (playertouchsme) {
toweapons RC;
hidelocal;
setstring rccolor,red;
setstring hasrc,#v(strtofloat(#s(hasrc))+1);
}
if (weaponfired && strtofloat(#s(hasrc))>0 && this.fired==0) {
// Setting up what happens when the weapon is fired
setstring hasrc,#v(strtofloat(#s(hasrc))-1);
this.fired=1;
disableweapons;
this.px=playerx;
this.py=playery;
this.dir=playerdir;
freezeplayer 1;
playersprite=14;
sleep 1;
timeout=0.05;
// Placement
if (playerdir=0) {
this.x=playerx+0.5;
this.y=playery-1;
}
if (playerdir=1) {
this.x=playerx-1.5;
this.y=playery+1;
}
if (playerdir=2) {
this.x=playerx+0.5;
this.y=playery+2.5;
}
if (playerdir=3) {
this.x=playerx+2.5;
this.y=playery+1;
}
}

if (timeout) {
if (this.fired==1) {
playerx=this.px;
playery=this.py;
playersprite=0;
showimg 0,shadoworb#v(this.dir).gif,this.x,this.y;
changeimgvis 0,1;
this.distx=abs(this.x-playerx);
this.disty=abs(this.y-playery);
if (this.distx<=this.disty){
if (this.y<playery)playerdir=0;
if (this.y>playery)playerdir=2;
}else{
if (this.x<playerx)playerdir=1;
if (this.x>playerx)playerdir=3;
}
if (keydown(0) || keydown(1) || keydown(2) || keydown(3)) {
if (keydown(0)) {
if (!onwall(this.x+1,this.y-this.speed)) this.y-=this.speed;
this.dir=0;
}
if (keydown(1)) {
if (!onwall(this.x-this.speed,this.y+1)) this.x-=this.speed;
this.dir=1;
}
if (keydown(2)) {
if (!onwall(this.x+1,this.y+2+this.speed)) this.y+=this.speed;
this.dir=2;
}
if (keydown(3)) {
if (!onwall(this.x+2+this.speed,this.y+1)) this.x+=this.speed;
this.dir=3;
}
if (this.speed>this.maxspeed) this.speed=this.maxspeed-this.accel;
if (this.acount>=this.accelcount) this.speed+=this.accel;
this.acount++;
}
if (!(keydown(0) || keydown(1) || keydown(2) || keydown(3))) {
if (this.speed>0) {
if (this.dir=0) if (!onwall(this.x+1,this.y-this.speed)) this.y-=this.speed;
if (this.dir=1) if (!onwall(this.x-this.speed,this.y+1)) this.x-=this.speed;
if (this.dir=2) if (!onwall(this.x+1,this.y+2+this.speed)) this.y+=this.speed;
if (this.dir=3) if (!onwall(this.x+2+this.speed,this.y+1)) this.x+=this.speed;
this.speed-=this.accel*3;
}
this.acount=0;
if (this.speed<0) this.speed=0;
}
if (keydown(4)) {
// Self Destruct
putexplosion 0,random(this.x-2,this.x+2),random(this.y-2,this.y+2);
putexplosion 0,random(this.x-2,this.x+2),random(this.y-2,this.y+2);
putexplosion 0,random(this.x-2,this.x+2),random(this.y-2,this.y+2);
sleep .4;
putexplosion 0,random(this.x-2,this.x+2),random(this.y-2,this.y+2);
putexplosion 0,random(this.x-2,this.x+2),random(this.y-2,this.y+2);
putexplosion 0,random(this.x-2,this.x+2),random(this.y-2,this.y+2);
sleep .6;
putexplosion 2,this.x,this.y;
this.fired=0;
this.speed=0;
hideimg 0;
enableweapons;
}
if (keydown(5)) {
// Reserved for when I decide to make a weapon for it.
}
if (keydown(6)) {
// Abandon Toy
if (this.dir==0)putnpc #s(rccolor)shadoworb.gif,thunder.txt,this.x,this.y;
if (this.dir==1)putnpc #s(rccolor)shadoworb.gif,thunder.txt,this.x,this.y;
if (this.dir==2)putnpc #s(rccolor)shadoworb.gif,thunder.txt,this.x,this.y;
if (this.dir==3)putnpc #s(rccolor)shadoworb.giff,thunder.txt,this.x,this.y;
this.fired=0;
this.speed=0;
hideimg 0;
enableweapons;
}
for (i=1;i<playerscount;i++) {
if (abs((this.x+1)-(players[i].x+1.5))<=3.5 &&abs((players[i].y+1.5)-(this.y+1))<=3.5) {
hitplayer i,1,this.x+1,this.y+1;
crash();
}
}
}
timeout=0.05;
}

if (playerchats) {
if (startswith(settoycolor,#c)) {
setstring rccolor, #e(11,-1,#c);
}
}

function crash () {
putexplosion 1,this.x,this.y;
this.fired=0;
this.speed=0;
hideimg 0;
enableweapons;
return;
}

